package com.mid;

/**
 * Created by Lxk on 2019/11/3.
 */
public class Solution260 {

    public int[] singleNumber(int[] nums) {
        int diffRes = 0;
        for (int val : nums) {
            diffRes = diffRes ^ val;
        }
        int mask = diffRes & (-diffRes);
        int res[] = new int[2];
        for (int i = 0; i < nums.length; i++) {
            if ((nums[i] & mask) == 0) {
                res[0] = res[0] ^ nums[i];
            } else {
                res[1] = res[1] ^ nums[i];
            }
        }
        return res;
    }

    public static void main(String[] args) {
        Solution260 solution260 = new Solution260();
        int[] arr = {1, 2, 1, 3, 2, 5};
        System.out.println(solution260.singleNumber(arr));
    }

}
